package com.example.moblie2030606150cjk0413;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private Button btnMainSupplier;
    private Button btnMainBuy;
    private TextView tvMainEsult;
    private Button btnMainClose;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder adBd = new AlertDialog.Builder(MainActivity.this);
                adBd.setTitle("提示框");
                adBd.setMessage("确定要关闭本应用程序吗？");
                adBd.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                });
                adBd.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
                adBd.create().show();
            }
        });
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        btnMainSupplier = (Button) findViewById(R.id.btn_main_supplier);
        btnMainBuy = (Button) findViewById(R.id.btn_main_buy);
        tvMainEsult = (TextView) findViewById(R.id.tv_main_esult);
        btnMainClose = (Button) findViewById(R.id.btn_main_close);
    }

}

